package com.xc.controller.protol;

import com.xc.common.ServerResponse;
import com.xc.service.IUserPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/2/19 12:18 PM
 */
@Controller
@RequestMapping("/user/position/")
@Slf4j
public class UserPositionController {

    @Autowired
    IUserPositionService iUserPositionService;

    /**
     *      获取我的持仓
     * @param request
     * @param pageNum
     * @param pageSize
     * @param state
     * @param stockCode
     * @param stockSpell
     * @return
     */
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse list(HttpServletRequest request,
                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                     @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
                                     @RequestParam(value = "state",required = false) Integer state,
                                     @RequestParam(value = "stockCode",required = false) String stockCode,
                                     @RequestParam(value = "stockSpell",required = false) String stockSpell){
        return iUserPositionService.findMyPositionByCodeAndSpell(stockCode,stockSpell,state,request,pageNum,pageSize);
    }


}
